import React from 'react';
import { Card } from 'antd';
import type { CardProps } from 'antd/es/card';

// 定义 Grid 项类型
interface GridItem {
    text: string;
    link: string;
}

// 组件 Props 类型
interface PlatformCardProps extends CardProps {
    title: string;
    gridItems: GridItem[];
    gridStyle?: React.CSSProperties;
}

const PlatformCard: React.FC<PlatformCardProps> = ({
    title,
    gridItems,
    gridStyle = {
        width: '100%',
        textAlign: 'center',
        cursor: 'pointer'
    },
    ...cardProps
}) => {
    const handleGridClick = (link: string) => {
        window.open(link, '_blank');
    };

    return (
        <Card
            title={title}
            {...cardProps}
            style={{ height: 207, overflow: 'auto', ...cardProps.style }}
        >
            {gridItems.map((item, index) => (
                <Card.Grid
                    key={index}
                    style={gridStyle}
                    onClick={() => handleGridClick(item.link)}
                >
                    {item.text}
                </Card.Grid>
            ))}
        </Card>
    );
};

export default PlatformCard;
